SUBROUTINE TABLE_S2
* Create a simple table using the RWS_TABLE routines and* populate it with data from a Reality file. Draw borders* round the cells.* Include the RealWeb definitions.
INCLUDE #RW.INCLUDE.DEFS FROM /SYSFILES/REALWEB,BP
EQU LF TO CHAR(10)
EQU TAB TO CHAR(9)
EQU AM TO CHAR(254)
EQU VM TO CHAR(253)
* Start the HTML page.CALL RW_START_HTML_PAGE("RWS_Table with Reality Data Example 1", "", "", "", "")* Initialise the HTML string buffer.
HTML = ""
* Create a caption for the table.
TEXT = "Hotel Guests"
CALL RWS_TABLE_CAPTION(TEXT, "")
HTML = HTML : TEXT
* Assemble some data to go in the table.
PERFORM "SORT-SPREAD GUESTS < '200' " : ...
"ROOM NAME ADDRESS CITY STATE ZIP ID-SUPP" ...
CAPTURING aData
* The headings are in the second attribute.
DEL aData<1>
aHeadings = aData<1>
* SORT-SPREAD returns tab-separated data; we need a dynamic array.
aHeadings = CHANGE(aHeadings, TAB, AM)
* The data is in the third attribute onwards.
DEL aData<1>
* SORT-SPREAD returns tab-separated data; we need a dynamic array.
aData = CHANGE(aData, TAB, VM)
* For each heading...
FOR I = 1 TO DCOUNT(aHeadings , AM)
* Tag the text as a heading cell.
S = aHeadings<I>
CALL RWS_TABLE_HEADER(S, "")
aHeadings<I> = S
NEXT I
* Tag the headings as a table row.CALL RWS_TABLE_ROW(aHeadings, "")
HTML = HTML : aHeadings
* For each data attribute...
FOR I = 1 TO DCOUNT(aData, AM)
* For each value in the attribute...
FOR J = 1 TO DCOUNT(aData<I>, VM)
* Tag the text as a table cell.
S = aData<I,J>
CALL RWS_TABLE_DATA(S, "")
aData<I,J> = S
NEXT J
* Tag the attribute as a table row.
S = aData<I>
CALL RWS_TABLE_ROW(S, "")
aData<I> = S
NEXT I
HTML = HTML : aData
* Give the table a 3 pixel border.
aClass = ""
aClass<2> = "3"
* Create the table.CALL RWS_TABLE(HTML, aClass)* Output the HTML.
HTML = CONVERT(HTML, AM:VM, LF:TAB)
CALL RW_PUT(HTML)* Complete the page.CALL RW_END_PAGE
RETURN
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><HTML><HEAD><META NAME="Generator" CONTENT="Reality"><TITLE>RWS_Table with Reality Data Example 1</TITLE></HEAD><BODY><TABLE BORDER="3"><CAPTION>Hotel Guests</CAPTION><TR><TH>Room</TH><TH>Guest Name</TH><TH>Address</TH><TH>City</TH><TH>State</TH><TH>Zip</TH></TR><TR><TD>
117
</TD><TD>
Loretta Rizzo
</TD><TD>
10 Webster St.
</TD><TD>
Harrington
</TD><TD>
TX
</TD><TD>
56634
</TD></TR><TR><TD>
119
</TD><TD>
Barry R. Scott
</TD><TD>
90 Alpine St.
</TD><TD>
Harrison
</TD><TD>
CT
</TD><TD>
66344
</TD></TR><TR><TD>
122
</TD><TD>
Richard T. Anderson
</TD><TD>
153 Windsor Dr.
</TD><TD>
Concord
</TD><TD>
NH
</TD><TD>
34598
</TD></TR><TR><TD>
140
</TD><TD>
Susan P. Lynch
</TD><TD>
55 Hale Rd.
</TD><TD>
Waltham
</TD><TD>
NM
</TD><TD>
22413
</TD></TR><TR><TD>
142
</TD><TD>
Jerry D. Madison
</TD><TD>
27411 Trabuco Circle
</TD><TD>
Mission Viejo
</TD><TD>
CA
</TD><TD>
92692
</TD></TR><TR><TD>
143
</TD><TD>
William Hennessey
</TD><TD>
11 Ellison Rd.
</TD><TD>
Lexington
</TD><TD>
MA
</TD><TD>
07745
</TD></TR><TR><TD>
144
</TD><TD>
Mr. & Mrs. H. Irving
</TD><TD>
20 Thorpe Rd.
</TD><TD>
Lexington
</TD><TD>
FL
</TD><TD>
28876
</TD></TR><TR><TD>
147
</TD><TD>
Loretta T. Janson
</TD><TD>
23 Glenborn Av.
</TD><TD>
Los Angeles
</TD><TD>
CA
</TD><TD>
07734
</TD></TR><TR><TD>
194
</TD><TD>
Mr. & Mrs. J. Hynes
</TD><TD>
90 Harlow Ct.
</TD><TD>
Stanton
</TD><TD>
LA
</TD><TD>
55278
</TD></TR><TR></TR></TABLE></BODY></HTML>